//
//  HJEmoticonPopoView.swift
//  HJWeiBo
//
//  Created by 夏航军 on 16/10/11.
//  Copyright © 2016年 夏航军. All rights reserved.
//

import UIKit
import pop

class HJEmoticonPopoView: UIView {

    @IBOutlet weak var emoticonButton: HJEmoticonButtton!
    
    
    //记录上一次点击的状态
    var lastEmoticon : HJEmoticon?
    
    //增加类方法,加载视图
    class func loadPopoView() -> HJEmoticonPopoView {
        let nib = UINib(nibName: "HJEmoticonPopoView", bundle: nil)
        
        return nib.instantiate(withOwner: nil, options: nil).last as! HJEmoticonPopoView
    }
    
    func show() {
        if let em = lastEmoticon {
            if em.chs == emoticonButton.emoticon?.chs {
                print("图片表情")
                return
            }
            if em.code == emoticonButton.emoticon?.code {
                print("emoji表情")
                return
            }
        }
        
        let anim = POPSpringAnimation(propertyNamed: kPOPLayerPositionY)!
        
        anim.fromValue = 40
        anim.toValue = 25
        
        anim.springSpeed = 20
        anim.springBounciness = 20
        
        emoticonButton.pop_add(anim, forKey: nil)
        //记录上次表情模型
        lastEmoticon = emoticonButton.emoticon
    }
    
}
